<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .btn {
        display: flex;
        width: 500px;
        justify-content: space-between;
    }

    .txt{
        position: absolute;
        top: 50px;
        background-color: rgb(240, 46, 182);
        width: 500px;
        height: 500px;

    }
    .html-contents{
        background-color: pink;
        width: 500px;
        height: 500px;
    }
    .css-contents{
        background-color: skyblue;
        width: 500px;
        height: 500px;
    }
    .js-contents{
        background-color: rgb(45, 216, 79);
        width: 500px;
        height: 500px;

    }
    .vuejs-contents{
        background-color: rgb(181, 236, 16);
        width: 500px;
        height: 500px;
    }
</style>

<body>


    <div id="app">
        <div class="btn">
            <div v-for="(value,index) in title">
                <button v-on:click="handler(index)">{{value.item}}</button>
            </div>
        </div>
        <div >
            <div class="txt">
                <div v-bind:class="ClassStr" >
                    {{name}}
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>
        let vm = new Vue({
            el: '#app',
            data: {
                ClassStr:' ',
                name:'',

                title: [
                    { item: 'html' },
                    { item: 'css' },
                    { item: 'js' },
                    { item: 'vuejs' },
                ],
                contents: [
                    { item: 'html-contents' },
                    { item: 'css-contents' },
                    { item: 'js-contents' },
                    { item: 'vuejs-contents' },
                ]
            },
            methods: {
                handler(index) {
                    this.ClassStr = this.contents[index].item
                    this.name=this.contents[index].item
                    // console.log(this.contents[index].item);
                }
            },
        })
    </script>
</body>

</html>